﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace DLL.Department
{
	/// <summary>
	/// 视图控制类
	/// </summary>
	/// <![CDATA[2014-8-7 17:52:59]]>
	public class View : DLL.ShowLayer.FormView
	{
		private Component clsthisComp;

		#region 添加、修改
		private TextBox tbDepartmentName = new TextBox();
		private DropDownList ddlParentDepartment = new DropDownList();
		#endregion 添加、修改

		#region 查询
		private TextBox tbQueryDepartmentName = new TextBox();
		private DropDownList ddlQueryParentDepartment = new DropDownList();
		#endregion 查询

		#region 浏览

		#endregion 浏览

		#region 构造函数
		/// <summary>
		/// 视图类构造函数
		/// </summary>
		/// <![CDATA[2014-8-11 16:11:52]]>
		public View(System.Web.UI.Page page)
			: base(page)
		{
			clsthisComp = new Component(page);

			clsComp = clsthisComp;

			clsControls.ShowDepartment(ddlParentDepartment);
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("单位", "TextBox", tbDepartmentName, "string", "strDepartmentName"));
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("上级单位", "DropDownList", ddlParentDepartment, "int", "nParentDepartmentID"));

			clsControls.ShowDepartmentWithAll(ddlQueryParentDepartment);
			listQuery.Add(new TonyNet4V1.Structs.TitleControlEntity("单位", "TextBox", tbQueryDepartmentName, "string", "strDepartmentName"));
			listQuery.Add(new TonyNet4V1.Structs.TitleControlEntity("上级单位", "DropDownList", ddlQueryParentDepartment, "int", "nParentDepartmentID"));
		}
		#endregion 构造函数

		#region 类型转换

		protected override TonyNet4V1.EntityBase GetEntity()
		{
			return new Entity();
		}

		protected override TonyNet4V1.QueryEntityBase GetQuery()
		{
			return new QueryEntity();
		}

		protected override TonyNet4V1.ComponentBase GetComponent()
		{
			return clsthisComp;
		}

		#endregion 类型转换

		public override bool QueryDefault(GridView gv)
		{
			//return base.QueryDefault(gv);
			List<Entity> list = new List<Entity>();

			list = clsthisComp.QueryAllOrder();
			clsthisComp.AddGradeInName(list, "|", "--");

			gv.DataSource = list;
			gv.DataKeyNames = new string[] { "ID" };
			gv.DataBind();

			return true;
		}
	}
}
